#!/bin/bash

f=(perl -pe 'binmode(STDOUT); s@^  [^ ]*Args_test(\.exe)?$@  Args_test@; s@Args_test\.exe@Args_test@')

# pipe "|&" is only available in bash version 4; prior to that the supported equivalent is "2>&1 |"

export TARGS_PHASE=0

Args_test | "${f[@]}"

TARGS_PHASE=1

echo '****'
Args_test 2>&1 | "${f[@]}"

echo '****'
Args_test -\? 2>&1 | "${f[@]}"

echo '****'
Args_test -unkflag u1 u2 e.a3d e2.a3d -flag -val1 3 2>&1 | "${f[@]}"

echo '****'
Args_test -farc 2 3 -val2 234 e.av -flac 2>&1 | "${f[@]}"

echo '****'
Args_test -flap -flag 2>&1 | "${f[@]}"

echo '****'
Args_test -show1p1 2>&1 | "${f[@]}"


echo '******'

TARGS_PHASE=2

echo '****'
Args_test file file.vlp -flag -showar 0 -showar 1 -vec2 1 2 file2 file2.vlp -showar 0 -showar 1 file.png 2>&1 | "${f[@]}"

echo '****'
Args_test file file.vlp -unknown.string -showar 0 2>&1 | "${f[@]}"

echo '****'
Args_test file -- file.vlp -unknown.string -showar 0 2>&1 | "${f[@]}"

echo '****'
Args_test file -- file.vlp -unknown.string file2 2>&1 | "${f[@]}"
